
/*
 * enqueue_hrtimer - internal function to (re)start a timer
 *
 * The timer is inserted in expiry order. Insertion into the
 * red black tree is O(log(n)). Must hold the base lock.
 *
 * Returns true when the new timer is the leftmost timer in the tree.
 */
static bool enqueue_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base,
                            enum hrtimer_mode mode)
{
    debug_activate(timer, mode);
    WARN_ON_ONCE(!base->cpu_base->online);

    base->cpu_base->active_bases |= 1 << base->index;

    /* Pairs with the lockless read in hrtimer_is_queued() */
    WRITE_ONCE(timer->state, HRTIMER_STATE_ENQUEUED);

    return timerqueue_add(&base->active, &timer->node);
}
